import {nanoid} from "nanoid";

export default {
    namespaced:true,
    state:{
        schoolName:'二师',
        schools:[{name:'光谷校区',id:'001'}]
    },
    actions:{
        addSch(context, data) {
            if(data.trim() !== ''){
                context.commit('ADDSCH', {name:data,id:nanoid()});
            }else{
                alert('学校名称为空')
            }
        },

        addHb(context, data) {
            if(data.indexOf('湖北') === 0){
                context.commit('ADDSCH', {name:data,id:nanoid()});
            }else{
                alert('学校名称不是以[湖北]开头')
            }
        }
    },
    mutations:{
        ADDSCH(state, data) {
            state.schools.push(data)

        }
    }
}
